package study.javaee.practice.service;

import study.javaee.practice.dao.JpaProjectDAO;
import study.javaee.practice.entity.JpaProject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class JpaProjectservice {
    @Autowired
    JpaProjectDAO projectdao;

    public JpaProject getbyname(String name){
        return projectdao.findByName(name);
    }

    public JpaProject save(JpaProject p){
        return projectdao.save(p);
    }

    public JpaProject getbyleaderid(int lid){
        return projectdao.getByleaderId(lid);
    }

    public JpaProject getbyunitid(int uid){
        return projectdao.getByunitId(uid);
    }

    public JpaProject deletebyid(int id){
        return projectdao.deleteById(id);
    }

    public List<Object> getfieldsbyLid(int lid) { return projectdao.findJoinByLeaderId(lid); }

    public List<Object> getfieldsbyState(int state) { return projectdao.find_Jpql_list_morefield_byState(state); }
}
